//
//  SchoolSectionController.m
//  MY_IGList_demo
//
//  Created by mac on 2019/3/19.
//  Copyright © 2019 Yilian. All rights reserved.
//

#import "SchoolSectionController.h"
#import "SchoolCollectionViewCell.h"
#import "SchoolModel.h"
#import "HScrollCollectionViewCell.h"
#import "HScrollSectionController.h"
@interface SchoolSectionController()//<IGListAdapterDataSource>

@property (nonatomic, strong) SchoolModel *model;

//@property (nonatomic, strong) IGListAdapter *adapter;

@end
@implementation SchoolSectionController


//- (IGListAdapter *)adapter{
//    if (!_adapter) {
//        _adapter = [[IGListAdapter alloc]initWithUpdater:[IGListAdapterUpdater new] viewController:self.viewController];
//        _adapter.dataSource = self;
//    }
//    return _adapter;
//}

- (instancetype)init {
    if (self = [super init]) {
        
        self.inset = UIEdgeInsetsMake(0, 0, 15, 0);
        
    }
    return self;
}


- (CGSize)sizeForItemAtIndex:(NSInteger)index{
    
    return CGSizeMake([[UIScreen mainScreen] bounds].size.width ,100);
}

- (__kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index{
    
    SchoolCollectionViewCell *cell = [self.collectionContext dequeueReusableCellWithNibName:@"SchoolCollectionViewCell" bundle:nil forSectionController:self atIndex:index];

    [cell setCellWithModel:self.model];
   
    return cell;
}

- (void)didUpdateToObject:(id)object{
    self.model = object;
}

- (void)didSelectItemAtIndex:(NSInteger)index{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"点击" message:[NSString stringWithFormat:@"%ld",index] preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:sure];
    [alert addAction:cancle];
    [self.viewController presentViewController:alert animated:YES completion:nil];
}

@end
